'''
	类型转换
'''


# 1. 基本类型
# 	Int, Float, Complex, Bool
# 
# 	分别是: int(),  float(),  complex(),  bool()
print( int(2.5) )
print( float(2) )
print( complex(2) )
print( complex(2,3) )
print( bool(1) )
print( bool(0) )
print( bool(0.0) )
print( bool(0+0j) )
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')

# 2. 注意
# ----------------------------------------
# 	1) Int()  支持float, bool, 纯数字字符串 (不能含有任意字母)
# 	2) Float() 支持float, int, bool, 数字字符串 (包含字母e, 小数点)
# 	3) Complex() 支持int, float, bool, 数字字符串 (包含字母e, 小数点)
# 	4) Bool() 
# 		以下值 都可以转为false, 其余都是true
# 			整数0
# 			小数0
# 			复数0
# 			空字符串
# 			空容器
# 			false 本身


# int()
# print( int(2+3j) )
print( int(True) )
print( int('123') )
# print( int('abc') )
# print( int('2e3') )
# print( int('2.3') )
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')



# float()
# print( float(2+3j) )
print( float(True) )
print( float('123') )
# print( float('abc') )
print( float('2e3') )
print( float('2.3') )
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')




# complex()
print( complex(2.5) )
print( complex(True, True) )
print( complex('123') )
# print( complex('abc') )
print( complex('2e3') )
print( complex('2.3') )
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')



# bool()
print( bool(999) )
print( bool(99.9) )
print( bool(1+2j) )
print( bool(1+0j) )
print( bool(0+1j) )
print( bool(0+0j) )
print( bool('') )
print( bool('123') )
print( bool('abc') )
print( bool('0') )

print( bool([]) )
print( bool(()) )
print( bool({}) )

a = set()
print( bool(a) )
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')





# 3. str()
# ----------------------------------------
# 	任何类型 都可以转换为string

print( str(123) )
print( str(123.4) )
print( str(True) )
print( str(1+2j) )

a = str([1,2,3])
a = str((1,2,3))
a = str({1,2,3})
a = str({1:2,3:4})
print(a, type(a) )
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')



# 4. List(), Tuple(), Set()
# 	支持string, list, tuple, set, dict 转换

# print( list(10) )
# print( list(10.5) )
# print( list(10.5 + 2j) )
# print( list(True) )

print( list('123') )
print( list( (1,2,3) ) )
print( list( {1,2,3} ) )
print( list( {1:2,3:4} ) ) 	# 字典 只保留的键
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')


# 5. Dict()
#	只有 二维容器 才能转为 字典
#	
#	二维容器: 容器中 嵌套别的容器

# 一维列表
a = ['a',1, 'b',2, 'c',3]

# 二维列表
a = {
		('a',1),
		('b',2),
		('c',3),
	}
print( dict(a) )














